using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using DatabaseProcess;

/// <summary>
/// Summary description for clsAdvertisement
/// </summary>
public class clsAdvertisement
{
    private int _id;

    public int Id
    {
        get { return _id; }
        set { _id = value; }
    }
    private string _url;

    public string Url
    {
        get { return _url; }
        set { _url = value; }
    }
    private string _image_url;

    public string Image_url
    {
        get { return _image_url; }
        set { _image_url = value; }
    }
    private DateTime _begin_date;

    public DateTime Begin_date
    {
        get { return _begin_date; }
        set { _begin_date = value; }
    }
    private DateTime _finish_date;

    public DateTime Finish_date
    {
        get { return _finish_date; }
        set { _finish_date = value; }
    }
    private string _name;

    public string Name
    {
        get { return _name; }
        set { _name = value; }
    }
    private string _phone_number;

    public string Phone_number
    {
        get { return _phone_number; }
        set { _phone_number = value; }
    }
    private string _address;

    public string Address
    {
        get { return _address; }
        set { _address = value; }
    }
    private string _information;

    public string Information
    {
        get { return _information; }
        set { _information = value; }
    }
    
	public clsAdvertisement()
	{
        this.Begin_date = DateTime.Now;
        this.Finish_date = Convert.ToDateTime("1/1/2010");
	}
    public int insertAds()
    {
        DBconnect connect = new DBconnect();
        connect.Open();
        if (connect.IsConnected == false)
            return -1;
        string[] listcol = new string[] { "url", "image_url", "begin_date", "finish_date", "name", "information", "address", "phone_number" };
        object[] listvalue = new object[] {this.Url, this.Image_url, this.Begin_date, this.Finish_date, this.Name, this.Information, this.Address, this.Phone_number };
        int i = connect.Insert("advertisement", listcol, listvalue);
        connect.Close();
        return i;
    }

    public DataTable GetAdver()
    {
        DBconnect db = new DBconnect();
        db.Open();
        DataTable kq = new DataTable();
        string sql = "select top 4 image_url,address from advertisement ORDER BY NEWID()";
        kq = db.GetDataTable(sql);
        return kq;


    }
}
